//
//  main.m
//  类设计
//
//  Created by mir_yan on 2018/9/26.
//  Copyright © 2018年 hakeem. All rights reserved.
//

#import <Foundation/Foundation.h>

// 结构体
struct Fraction {
    int fenzi;
    int fenmu;
};

typedef struct Fraction MFraction;

MFraction addFraction(MFraction num1,MFraction num2) {
    int newFenzi = num1.fenzi*num2.fenmu + num1.fenmu*num2.fenzi;
    int newFenmu = num1.fenmu*num2.fenmu;
    
    MFraction newFrac = {newFenzi,newFenmu};
    return newFrac;
}

void showFraction(MFraction num) {
    NSLog(@"%d/%d",num.fenzi,num.fenmu);
}

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        
        MFraction num1 = {1, 3};
        MFraction num2 = {2, 3};
        
        MFraction newnum = addFraction(num1, num2);
        
        showFraction(newnum);
        
        showFraction(num1);
        showFraction(num2);

        NSLog(@"Hello, World!");
    }
    return 0;
}
